# 使用 mitmproxy 官方基础镜像
FROM mitmproxy/mitmproxy

# 指定工作空间
WORKDIR /home/mitmproxy/

# 将脚本复制到容器内
COPY source/mitmproxy_plugin.py /home/mitmproxy/
COPY source/client2.pem /home/mitmproxy/
COPY .mitmproxy/ /home/mitmproxy/.mitmproxy/

# 授予执行权限
RUN chmod +x /home/mitmproxy/

# 安装依赖
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install Brotli==1.0.9 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install Flask==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install Jinja2==3.1.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install MarkupSafe==2.1.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install aioquic==1.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install annotated-types==0.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install asgiref==3.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install attrs==23.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install blinker==1.7.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install certifi==2024.2.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install cffi==1.16.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install charset-normalizer==3.3.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install click==8.1.7 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install colorama==0.4.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install cryptography==42.0.7 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install h11==0.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install h2==4.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install hpack==4.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install hyperframe==6.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install idna==3.7 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install itsdangerous==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install kaitaistruct==0.10 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install ldap3==2.9.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install mitmproxy==10.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install mitmproxy-rs==0.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install mitmproxy-wireguard==0.1.23 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install msgpack==1.0.8 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install passlib==1.7.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install protobuf==4.25.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install publicsuffix2==2.20191221 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pyOpenSSL==24.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pyasn1==0.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pyasn1-modules==0.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pycparser==2.22 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pydantic==2.7.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pydantic-core==2.18.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pydivert==2.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pylsqpack==0.3.18 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pyparsing==3.0.9 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install pyperclip==1.8.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install python-multipart==0.0.9 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install requests==2.31.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install requests-toolbelt==1.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install ruamel.yaml==0.17.32 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install ruamel.yaml.clib==0.2.8 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install service-identity==24.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install setuptools==65.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install sortedcontainers==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install tornado==6.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install typing-extensions==4.11.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install urllib3==2.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install urwid==2.1.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install urwid-mitmproxy==2.1.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install werkzeug==3.0.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install wsproto==1.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install zstandard==0.19.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install beautifulsoup4==4.12.3 -i https://pypi.tuna.tsinghua.edu.cn/simple

# 修改了mitmproxy源文件
COPY source/app.js /usr/local/lib/python3.11/site-packages/mitmproxy/tools/web/static/
COPY source/app.py /usr/local/lib/python3.11/site-packages/mitmproxy/tools/web/
COPY source/http.py /usr/local/lib/python3.11/site-packages/mitmproxy/
